﻿namespace Sai.Core.Reporting
{
	using System;
	using System.IO;

	/// <summary>
	/// Generates report output as plain xml documents.
	/// </summary>
	public class XmlReportFormatter : IReportFormatter
	{
		public string Extension 
		{ 
			get 
			{ 
				return ".xml"; 
			} 
		}

		public void Execute(IFlattenToXml flattenable, IReportTransformation transformation, IReportOutput output)
		{
            try
            {
                // already in xml - no transformation needed.
                output.Execute(flattenable.ToXml());
            }
            catch (Exception ex)
            {
                throw new ReportGenerationException(string.Format("Error generating xml report {0}", output.Path), ex);
            }
		}
	}
}
